<script setup lang="ts">
import useUser from '@/store/user'
import { useRouter } from 'vue-router'
const router = useRouter()
const user = useUser()
// 退出登录
const jumpLogin = () => {
  router.push('/login')
}
</script>
<template>
  <div class="userinfo">
    <div class="icon">
      <span>
        <el-icon size="20" color="#fff"><Search /></el-icon>
      </span>
      <span>
        <el-icon size="20" color="#fff"><ChatDotRound /> </el-icon>
      </span>
      <span>
        <el-icon size="20" color="#fff"><Setting /></el-icon>
      </span>
    </div>
    <div class="user">
      <el-dropdown trigger="click">
        <div class="avatar">
          <el-avatar :size="50" :src="user.user.avatar" />
          <span class="el-dropdown-link">
            {{ user.user.name }}
            <el-icon class="el-icon--right"><arrow-down /></el-icon>
          </span>
        </div>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人信息</el-dropdown-item>
            <el-dropdown-item divided @click="jumpLogin"
              >退出登录</el-dropdown-item
            >
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<style scoped lang="scss">
.userinfo {
  display: flex;
  align-items: center;

  .icon {
    margin-right: 20px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    span {
      margin-right: 10px;
    }
  }
  .user {
    .avatar {
      display: flex;
      align-items: center;
      .el-avatar {
        margin-right: 10px;
      }
      .el-dropdown-link {
        display: flex;
        align-items: center;
        color: $them-font-color;
        font-size: 18px;
      }
    }
  }
}
</style>
